package com.lzq.leetcode.hoot100;

public class s240 {

    public boolean searchMatrix(int[][] matrix, int target) {

        int m = matrix.length;
        int n = matrix[0].length;
        int x = 0, y = n-1;
        while (x < m && y >= 0) {

            if (matrix[x][y] == target) {
                return true;
            } else if (matrix[x][y] < target) {
                ++x;
            } else {
                --y;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new s240().searchMatrix(new int[][]{{-5}}, -10));
    }
}
